﻿Imports System.Collections.Generic
Imports System.Linq
Imports EnvDTE

Public Class ProjectHolderCollection
  Inherits System.Collections.Generic.List(Of ProjectHolder)

  Public Function GetByProject(project As Project) As ProjectHolder
    Dim ret As ProjectHolder = _
      Me.FirstOrDefault(Function(x) x.Project Is project)
    Return ret
  End Function

  Public Function Clone() As ProjectHolderCollection
    Dim ret As New ProjectHolderCollection
    ret.AddRange(Me)
    Return ret
  End Function

  Sub RemoveIfExists(sourceProject As ProjectHolder)
    If Me.Contains(sourceProject) Then _
      Me.Remove(sourceProject)
  End Sub

  Function CloneWithout(projectToRemoveIfExists As ProjectHolder) As ProjectHolderCollection
    Dim ret = Me.Clone()
    If ret.Contains(projectToRemoveIfExists) Then ret.Remove(projectToRemoveIfExists)
    Return ret
  End Function

End Class
